<template>
	<view class="tabs-container">
		<template v-for="tab in tabs">
			<view class="tab" :class="{active: select === tab.id}" @click="change(tab)">
				{{tab.label}}
			</view>
		</template>
	</view>
</template>

<script>
	export default {
		name: "tabs",
		props: {
			tabs: {
				type: Object,
				default: () => ({})
			},
			select: {
				type: Number,
				default: 0
			}
		},
		methods: {
			change(tab) {
				this.$emit('onChange', tab)
			}
		}
	}
</script>

<style lang="less" scoped>
	.tabs-container {
		display: flex;

		.tab {
			flex: 1;
			text-align: center;
			height: 60px;
			line-height: 60px;
			background-color: #fff;
			padding: 0 10px;
			font-size: 16px;
			position: relative;
		}

		.active {
			&::after {
				position: absolute;
				bottom: 0;
				left: 0;
				content: " ";
				height: 3px;
				width: 100%;
				background-color: #c7984a;
			}
		}
	}
</style>
